/***     
 * 找💣
 */

var _ = require('./../../FrameWork/we_underscore');
var FindCardTool = require('./FindCardTool');


var FindBomb = module.exports = {};

/***是否为炸弹*/
FindBomb.isBomb = function(_cardInfoList) {
    var size = _.size(_cardInfoList);
    if (4 != size) {
        return false;
    }
    var isFind = _cardInfoList[0].value == _cardInfoList[1].value &&
        _cardInfoList[0].value == _cardInfoList[2].value &&
        _cardInfoList[0].value == _cardInfoList[3].value;
    return isFind;
};


/***是否为王炸弹*/
FindBomb.isBombKing = function(_cardInfoList) {
    var size = _.size(_cardInfoList);
    if (2 != size) {
        return false;
    }
    var isFind = (5 == _cardInfoList[0].cardType && 5 == _cardInfoList[1].cardType)
    return isFind;
};

/***找王炸弹*/
FindBomb.getResultKing = function(_cardInfoList) {
    var result = {
        isFind: false,
        findGroup: []
    };
    var size = _.size(_cardInfoList);
    if (size >= 2) {
        var result = {
            isFind: false,
            findGroup: [],
            otherGroup: _cardInfoList
        };
    }
    var resultCan = FindCardTool.getResult(_cardInfoList, function(_cardInfo) {
        return (5 == _cardInfo.cardType || 5 == _cardInfo.cardType);
    }, function(_cardInfo) {
        return !(5 == _cardInfo.cardType || 5 == _cardInfo.cardType);
    });
    if (2 == _.size(resultCan.findGroup)) {
        return resultCan;
    }
    return result;
};